package model

import "time"

// PickingTask 表示一个分拣任务
type PickingTask struct {
	ID             string        `gorm:"primaryKey" json:"id"`
	OrderID        string        `gorm:"index" json:"order_id"`
	WaveID         *string       `gorm:"size:255" json:"wave_id,omitempty"`
	Status         PickingStatus `json:"status"`
	AssignedTo     string        `json:"assigned_to"` // 分配给哪个分拣员
	StartTime      time.Time     `json:"start_time"`
	EndTime        time.Time     `json:"end_time"`
	Items          []PickingItem `gorm:"foreignKey:TaskID" json:"items"`
	Location       Location      `gorm:"embedded" json:"location"`
	Priority       int           `json:"priority"`
	CreateTime     time.Time     `json:"create_time"`
	LastUpdateTime time.Time     `json:"last_update_time"`
}

// PickingItem 表示分拣任务中的一个商品项
type PickingItem struct {
	ID         uint              `gorm:"primaryKey;autoIncrement" json:"id"`
	TaskID     string            `gorm:"index" json:"task_id"`
	ProductID  string            `json:"product_id"`
	SKU        string            `json:"sku"`
	Quantity   int               `json:"quantity"`
	PickedQty  int               `json:"picked_qty"` // 已分拣数量
	PackedQty  int               `json:"packed_qty"` // 已打包数量
	Status     PickingItemStatus `json:"status"`
	Location   string            `json:"location"` // 商品在仓库中的位置
	CreateTime time.Time         `json:"create_time"`
	UpdateTime time.Time         `json:"update_time"`
}

// PickingStatus 分拣任务状态枚举
type PickingStatus int

const (
	PickingStatusPending PickingStatus = iota
	PickingStatusInProgress
	PickingStatusPicked
	PickingStatusPacked
	PickingStatusCompleted
	PickingStatusCancelled
)

// PickingItemStatus 分拣项状态枚举
type PickingItemStatus int

const (
	PickingItemStatusPending PickingItemStatus = iota
	PickingItemStatusPicking
	PickingItemStatusPicked
	PickingItemStatusPacking
	PickingItemStatusPacked
	PickingItemStatusCompleted
)

// TableName 指定表名
func (PickingTask) TableName() string {
	return "picking_tasks"
}

// TableName 指定表名
func (PickingItem) TableName() string {
	return "picking_items"
}
